﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Service.Registers;
using Service.Registers.Dto;

namespace UI.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class RegisterController : ControllerBase
    {
        private readonly IRegisterService registerService;

        public RegisterController(IRegisterService registerService)
        {
            this.registerService = registerService;
        }

        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="registerDto"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult Register(RegisterDto registerDto)
        {
            return Ok(registerService.UserRegister(registerDto));
        }

        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="registerDto"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult Login(LoginDto loginDto)
        {
            return Ok(registerService.UserLogin(loginDto));
        }

        [HttpGet]
        [Authorize]
        public IActionResult Create()
        {
            return Ok();
        }
    }
}
